<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container">
    <div class="box">
        <form action="{$Action}" method="post" id="frmAdd" enctype="multipart/form-data">
            <div class="box-header"><h4>活动基本信息</h4></div>
            <div class="box-content">
                <table class="boxtable">
                  <tr>
                    <th nowrap="nowrap">抽奖形式</th>
                    <td>
                        <label><input type="radio" name="LotteryType" value="0" checked="checked" onclick="SelectType(0)"  />大转盘</label>&nbsp;&nbsp;&nbsp;&nbsp;
                        <label><input type="radio" name="LotteryType" value="1"   onclick="SelectType(1)"   />刮刮卡</label>
                    </td>
                </tr>
                    <tr>
                        <th>活动名称</th>
                        <td><input type="text" class="textinput w450"  id="LotteryName" name="LotteryName" value="" /></td>
                    </tr>
                    <tr>
                        <th>触发关键词</th>
                        <td><input type="text" class="textinput" style="230px"  id="AppKeyword" name="AppKeyword" value="" />
                        <span class='Caution'>在微信输入此关键词，将返回当前应用的图文消息！</span>
                        </td>
                    </tr>
                 <tr>
                    <th>图文消息封面</th>
                    <td><input type="text" id="wxlotterypictureImage" class="textinput w450" name="LotteryStartPicture" value="{$WebPublic}tpl/wx/images/wheel.jpg"  />
                    <span class='UploadWrapper'>
                        <input class='btnFileUpload' type='button' value='上传' />
                        <input id='wxlotterypicture' name ='wxlotterypicture' type ='file'  size='70'   class='InputFile'  accept="image/*" />
                    </span>
                    <input id='btnServer' onclick='BrowserServer(1)' name ='btnServer'  type ='button' value='{$Think.lang.SelectPicture}'  class='btnUpload' />
                    </td>
                </tr>
                    <tr>
                        <th>活动简介</th>
                        <td><input type="text" class="textinput w450" name="LotteryIntroduction" value=""  /></td>
                    </tr>
                    <tr>
                        <th>活动说明</th>
                        <td><textarea class="w450" style="height:50px; width:100%" name="LotteryDescription"></textarea></td>
                    </tr>
                   <tr>
                        <th>活动时间</th>
                        <td><script type='text/javascript' src='{$WebPublic}My97DatePicker/WdatePicker.js'></script>
                        <input name='LotteryStartTime' type='text' class='Wdate' id='LotteryStartTime'  class='textinput' style="width:140px"  onClick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly='readonly'   value='{$StartTime}' /><span style="padding:0px 5px">到</span><input name='LotteryEndTime' type='text' class='Wdate' id='LotteryEndTime'  class='textinput' style="width:140px"  onClick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly='readonly'   value='{$EndTime}' />
                        </td>
                    </tr>
                    <tr>
                        <th>重复抽奖回复</th>
                        <td><input type="text" class="textinput w450" name="LotteryRepeatTip" value="你已经玩过了，下次再来！"  /></td>
                    </tr>
                    
                  </table>
            </div>
            
            <div class="box-header"><h4>活动结束内容</h4></div>
            <div class="box-content">
                <table class="boxtable">
                    <tr>
                        <th>活动结束标题</th>
                        <td><input type="text" class="textinput w450" name="LotteryEndTitle" value="活动已经结束" /></td>
                    </tr>
                    <tr>
                        <th>活动结束说明</th>
                        <td>
                        <textarea class="w450" style="height:50px; width:100%" name="LotteryEndDescription">亲，活动已经结束，所有奖品已经发放完毕。下次早点哦！请继续关注我们的后续活动，谢谢！</textarea>
                        </td>
                    </tr>
                </table>
           </div>
           
            <div class="box-header"><h4>活动奖项</h4></div>
            <div class="box-content">
                <table class="boxtable">
                    <tr>
                        <th>一等奖奖品</th>
                        <td>
                        <input type="text" class="textinput"  style="width:160px" name="LotteryAward1" value="奖品1" />&nbsp;
                        奖品数量<input type="text" class="textinput" style="width:40px" name="LotteryAward1Num" value="1" />
                        &nbsp;
                        中奖概率<input type="text" class="textinput" style="width:40px" name="LotteryAward1Probability" value="1" />
                        <span class='Caution'>单位：万分比，取值范围[0-10000]。0：不可能中奖，10000：一定可以中奖</span>
                        </td>
                    </tr>
                    <tr>
                        <th>二等奖奖品</th>
                        <td>
                        <input type="text" class="textinput"  style="width:160px" name="LotteryAward2" value="奖品2" />&nbsp;
                        奖品数量<input type="text" class="textinput" style="width:40px" name="LotteryAward2Num" value="2" />
                        &nbsp;
                        中奖概率<input type="text" class="textinput" style="width:40px" name="LotteryAward2Probability" value="5" />
                        <span class='Caution'>单位：万分比，取值范围[0-10000]。0：不可能中奖，10000：一定可以中奖</span>
                        </td>
                    </tr>
                     <tr>
                        <th>三等奖奖品</th>
                        <td>
                        <input type="text" class="textinput"  style="width:160px" name="LotteryAward3" value="奖品3" />&nbsp;
                        奖品数量<input type="text" class="textinput" style="width:40px" name="LotteryAward3Num" value="5" />
                        &nbsp;
                        中奖概率<input type="text" class="textinput" style="width:40px" name="LotteryAward3Probability" value="10" />
                        <span class='Caution'>单位：万分比，取值范围[0-10000]。0：不可能中奖，10000：一定可以中奖</span>
                        </td>
                    </tr>
                     <tr>
                        <th>每人最多抽奖总次数</th>
                        <td>
                        <input type="text" class="textinput"  style="width:160px" name="LotteryMax" value="1" />
                         <span class='Caution'>推荐设置为1-5次</span>
                        </td>
                    </tr>
                    <tr>
                        <th>每天最多抽奖次数</th>
                        <td>
                        <input type="text" class="textinput"  style="width:160px" name="LotteryDayMax" value="1" />
                         <span class='Caution'>必须大于0，最大不能超过"每人最多抽奖总次数"，推荐设置为1次</span>
                        </td>
                    </tr>
                    <tr>
                        <th>兑奖说明</th>
                        <td>
                        <input type="text" class="textinput"  style="width:450px" name="LotteryTip" value="" />
                         <span class='Caution'>中奖后的提示信息！如：请联系我们兑奖，电话：189xxxxxxx8</span>
                        </td>
                    </tr>
                    <tr>
                        <th>商家兑奖密码</th>
                        <td>
                        <input type="text" class="textinput"  style="width:160px" name="LotteryPassword" value="" />
                         <span class='Caution'>用于商家兑奖！</span>
                        </td>
                    </tr>
                </table>
           </div>

            <div class="box-header"><h4>其它选项</h4></div>
            <div class="box-content">
                <table class="boxtable">
                    <tr>
                        <th>操作说明</th>
                        <td>
                        <textarea class="w450" style="height:50px; width:100%" name="AppDescription"></textarea>
                        </td>
                    </tr>
                     <tr>
                    <th nowrap="nowrap">是否启用</th>
                    <td>
                        <label><input type="radio" name="IsEnable" value="1" checked="checked"  />启用</label>&nbsp;&nbsp;
                        <label><input type="radio" name="IsEnable" value="0"  />禁用</label>
                    </td>
                    </tr>
                </table>
           </div>

            <div class="box-footer">
                <div class="box-footer-inner">
                    <input  id="btnSubmit" class="marginright" type="submit"  value="保存并继续添加" />
                    <input  id="btnSubmit"  type="button" value="返回" class="GoBack"  onclick="GoBack()" />
                </div>
            </div>
        </form>
    </div>
</div>
</body>
</html>
<script type='text/javascript'>
function BrowserServer(){
	var finder = new CKFinder();
	finder.basePath = '{$WebPublic}ckfinder'; 
	finder.selectActionFunction = SetPictureField;
	finder.popup(); 
}

function SetPictureField(fileUrl){
	document.getElementById('wxlotterypictureImage').value = fileUrl;
}

$(document).ready(function(){
	$('#frmAdd').ajaxForm({
		success: complete,
		dataType: 'json'
	});
	
	function complete(data){
		CloseLoadBox();
		if (data.status==1){
			SucceedBox(data.info);
			$('#frmAdd').resetForm();
			SelectType(0);
			$('#LotteryName').focus();
		}else if(data.status==0){
			ErrorBox(data.info);
		}else if(data.status==2){
			ErrorBox(data.info); //上传失败
		}else if(data.status==3){
			$('#'+data.data.ImageField).val(data.data.Path);
			SucceedBox(data.info); //上传成功
		}
	};
	
	 $('#frmAdd').submit(function(){
		LoadBox();
		return false;  //为了防止普通浏览器进行表单提交和产生页面导航（防止页面刷新？）返回false  
	 });
	 
	 $('#wxlotterypicture').change(function(){
		 if( !$(this).val() ) return;
		$('#frmAdd').attr('action','{$UploadAction}/currentfile/wxlotterypicture');
		$('#frmAdd').submit();
	 });
	 
	 $('#btnSubmit').click(function(){
		$('#frmAdd').attr('action','{$Action}');
	 });
	 $("#wxlotterypictureImage").powerFloat({targetMode: "ajax",	targetAttr: "value",	position: "5-7" });
	 $('#LotteryName').focus();
});

function GoBack(){
	window.location.href = "{$Url}lottery";
}

function SelectType(type){
	var p1 = "{$WebPublic}tpl/wx/images/wheel.jpg";
	var p2 = "{$WebPublic}tpl/wx/images/scratch.jpg";
	var pic = $("#wxlotterypictureImage").val();
	if( p1 == pic || p2 == pic || pic==''){
		var t = (type==0) ? p1 : p2;
		$("#wxlotterypictureImage").val( t );
	}
}
</script>